var express = require('express'),
    swig = require('swig-templates'),
    request = require('request'),
    router = express.Router(),
    common = require('../base/common.js');
router.get('/book-install',function(req, res,next) {
    var url=config.resourcePath.apiRoot + "/index.php?m=BookInstall&a=getInstall",
        postData={
            p_id: req.query.pid?req.query.pid:req.cookies.p_id
        },
        redirectUrl='haier/portal/mi/anzhuang/go_anzhuang?',
        cssLink='<link rel="stylesheet" href="http://code.haier.net/css/pages/alert.css">',
        successTip=req.cookies.u_id ? encodeURIComponent([cssLink+'<div class="thare-alert-model-box"><div class="header"><div class="Model_Ok"></div><h3>提交成功</h3></div><main><h4>您的预约已提交,我们将很快和您联系</h4><p></p></main><div class="footer"><a class="HrWx_GZ_focus" href="http://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzIwNzE3NjU1MA==&amp;scene=124#wechat_redirect">关注</a><p style="font-size: 14px;">登录或注册,及时了解进度,享受会员权益</p></div></div>'].join('')):
            encodeURIComponent([cssLink+'<div class="thare-alert-model-box"><div class="header"><div class="Model_Ok"></div><h3>提交成功</h3></div><main><h4>您的预约已提交,我们将很快和您联系</h4><p></p></main><div class="footer"><a class="HrWx_GZ" href="/login">立即登录/或注册</a><p style="font-size: 14px;">登录或注册,及时了解进度,享受会员权益</p></div></div>'].join('')),
        failTip='',
        redirectData= {
            'brandId':encodeURIComponent(req.query.brandId?req.query.brandId:req.cookies.brandId || ''),
            'mainProductId':encodeURIComponent(req.query.mainProductId?req.query.mainProductId:req.cookies.mainProductId || ''),
            'productId':encodeURIComponent(req.query.productId?req.query.productId:req.cookies.p_mid_c || ''),
            'phone': encodeURIComponent(req.query.phone?req.query.phone:req.cookies.phone_number || ''),
            'username': encodeURIComponent(req.query.username?req.query.username:req.cookies.username || ''),
            'address':encodeURIComponent(req.query.address?req.query.address:req.cookies.address || ''),
            'memLevel':encodeURIComponent(req.cookies.memLevel || ''),
            'successTip': successTip,
            'failTip': failTip
        };
    if(req.cookies.u_id && req.cookies.u_id!='undefined'){
        // postData['u_id']=req.cookies.u_id;
        // url=config.resourcePath.apiRoot + "/index.php?m=BookInstall&a=getLoginInstall";
    }
    if(req.query.type=='2'){
        redirectUrl='haier/portal/mi/weixiu/go_weixiu?';
    }
    redirectData.redirectUrl=config.resourcePath.redirectRoot+redirectUrl;
    res.render('my-haier/book_install/book_install',redirectData);
});
module.exports = router;
